import request from '@/utils/request'

// 查询论文列表
export function listPapers(query) {
  return request({
    url: '/result/papers/list',
    method: 'get',
    params: query
  })
}

// 查询论文详细
export function getPapers(id) {
  return request({
    url: '/result/papers/' + id,
    method: 'get'
  })
}
/**
 * 根据多个id批量查询论文信息
 */
export function getPapersByIds(ids) {
  return request({
    url: `/result/papers/getPapersByIds`,
    method: 'get',
    params: { ids: ids.join(',') } // 将数组转换为逗号分隔的字符串
  });
}


// 新增论文
export function addPapers(data) {
  return request({
    url: '/result/papers',
    method: 'post',
    data: data
  })
}

// 修改论文
export function updatePapers(data) {
  return request({
    url: '/result/papers',
    method: 'put',
    data: data
  })
}

// 删除论文
export function delPapers(id) {
  return request({
    url: '/result/papers/' + id,
    method: 'delete'
  })
}

export const paperApi = {
  getPapers(params) {
    return request.post('/result/papers/getPapers', params);
  },
  deletePaper(id) {
    return request.delete(`/result/papers/deleteById/${id}`);
  }
};

/**
 * 根据id来查询论文信息
 */
export function getPaperById(id) {
  return request({
    url: '/result/papers/getPapersById/' + id,
    method: 'get'
  })
}


/**
 * 更新论文信息
 */
export function updatePaper(paperData) {
  return request.put('/result/papers/update', paperData);
}
/**
 * excel批量导出
 */
// export function exportPaper(params) {
//   return request.post(`http://localhost:8080/papers/export/papers`, params, {
//     responseType: 'blob'
//   });
// }
export function exportPaper(params) {
  return request.post(`/result/papers/export/papers`, params, {
    responseType: 'blob'
  })
}

